home *** CD-ROM | disk | FTP | other *** search
- #include "compiler_defines.h"
- #include "ASStreamIterator.h"
-
- #include <iostream>
- #include <fstream>
- #include <string>
-
- using namespace astyle;
-
- ASStreamIterator::ASStreamIterator(istream *in)
- {
- inStream = in;
- }
-
- ASStreamIterator::~ASStreamIterator()
- {
- delete inStream;
- }
-
-
- bool ASStreamIterator::hasMoreLines() const
- {
- if (*inStream)
- return true;
- else
- return false;
- }
-
- /*
- string ASStreamIterator::nextLine()
- {
- char theInChar;
- char peekedChar;
- int theBufferPosn = 0;
-
- //
- // treat '\n', '\r', '\n\r' and '\r\n' as an endline.
- //
- while (theBufferPosn < 2047 && inStream->get(theInChar))
- // while not eof
- {
- if (theInChar != '\n' && theInChar != '\r')
- {
- buffer[theBufferPosn] = theInChar;
- theBufferPosn++;
- }
- else
- {
- peekedChar = inStream->peek();
- if (peekedChar != theInChar && (peekedChar == '\r' || peekedChar == '\n') )
- {
- inStream->get(theInChar);
- }
- break;
- }
- }
- buffer[theBufferPosn] = '\0';
-
- return string(buffer);
- }
- */
-
-
- string ASStreamIterator::nextLine()
- {
- char *srcPtr;
- char *filterPtr;
-
- inStream->getline(buffer, 2047);
- srcPtr = filterPtr = buffer;
-
- while (*srcPtr != 0)
- {
- if (*srcPtr != '\r')
- *filterPtr++ = *srcPtr;
- srcPtr++;
- }
- *filterPtr = 0;
-
- return string(buffer);
- }
-
-